package com.my.test.thread.concurrent;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class TestCyclicBarrier {


    static CyclicBarrier clb = new CyclicBarrier(10, new Thread(new Runnable() {
        @Override
        public void run() {
            System.out.println("input");
        }
    }));

    public static void main(String[] args) throws BrokenBarrierException, InterruptedException {
        for (int i = 0; i < 9; i++) {
            new Thread(() -> {
                try {
                    clb.await();
                    System.out.println("ss");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (BrokenBarrierException e) {
                    e.printStackTrace();
                }
            }).start();
        }
        clb.await();
        System.out.println("mian");
    }
}
